// pages/mymy/mymy.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    zhuangtai:true,
    radio:"0",
    chuhan:"0",
    qiguan:"0",
    shaoshang:"0",
    number:'',
    bed_number:'',
    age:"",
    high:'',
    weight:'',
    temperature:'',
    xiugai:'1'
  },
  gogogo(){
    wx.redirectTo({
      url: '/pages/liquidlog/index',
    })
  },
  gotongji(){
    wx.redirectTo({
      url: '/pages/mygogo/mygogo',
    })
  },
  goindex(){
    wx.redirectTo({
      url: '/pages/mymy/mymy',
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  xinxi(){
    wx.request({
      url: 'https://server.ifufan.com/Index/Liquid/question_detail',
      method:"POST",
      data:{
        userid:wx.getStorageSync('userid')
      },
      success:(res)=>{
        wx.setStorageSync('id', res.data.data.id)
        this.setData({
          number:res.data.data.number,
          bed_number:res.data.data.bed_number,
          age:res.data.data.age,
          high:res.data.data.high,
          weight:res.data.data.weight,
          temperature:res.data.data.temperature,
          radio:(res.data.data.sex+1).toString(),
          chuhan:(res.data.data.sweat).toString(),
          qiguan:(res.data.data.cut +1).toString(),
          shaoshang:(res.data.data.burn+1).toString()
        }),
        console.log(res,"信息")
      }
    })
  },

// 修改信息
  xiugai(){
    wx.request({
      url: 'https://server.ifufan.com/Index/Liquid/update_question',
      method:"POST",
      data:{
        userid:wx.getStorageSync('userid'),
        id:wx.getStorageSync('id'),
        number:this.data.number,
        bed_number:this.data.bed_number,
        sex:this.data.radio-1,
        age:this.data.age,
        high:this.data.high,
        weight:this.data.weight,
        temperature:this.data.temperature,
        sweat:this.data.chuhan,
        cut:this.data.qiguan-1,
        burn:this.data.shaoshang-1
      },
      success:(res)=>{
       
        console.log(res,"信息")
        this.xinxi()
      }
    })
  },


  onChange5(event) {
    console.log(event,'123456')
    if(event.detail==1){
      this.setData({
        sex:"男"
      })
    }else{
      this.setData({
        sex:'女'
      })
    }
    this.setData({
      radio: event.detail,
    });
  },
  onChange4(event) {
    // console.log(event,'123')
    if(event.detail==1){
      this.setData({
        sweat:'明显'
      })
    }else if(event.detail==2){
      this.setData({
        sweat:'湿透衣裤'
      })
    }else if(event.detail==3){
      this.setData({
        sweat:'一般'
      })
    }else{
      this.setData({
        sweat:'几乎不出汗'
      })
    }
    this.setData({
      chuhan: event.detail,
    });
  },
  onChange2(event) {
    // console.log(event,'123')
    if(event.detail==1){
      this.setData({
        cut:'是'
      })
    }else{
      this.setData({
        cut:'否'
      })
    }
    this.setData({
      qiguan: event.detail,
    });
  },
  onChange3(event) {
    // console.log(event,'123')
    if(event.detail==1){
      this.setData({
        burn:'是'
      })
    }else{
      this.setData({
        burn:'否'
      })
    }
    this.setData({
      shaoshang:event.detail,
    });
  },
  number(e){
    this.setData({
      number:e.detail.value
    })
    // console.log(this.number);
  },
  bed_number(e){
    this.setData({
      bed_number:e.detail.value
    })
    console.log(e.detail.value)
  },
  age(e){
    this.setData({
      age:e.detail.value
    })
    // console.log(e)
  },
  high(e){
    this.setData({
      high:e.detail.value
    })
  },
  weight(e){
    this.setData({
      weight:e.detail.value
    })
    // console.log(e)
  },
  temperature(e){
    this.setData({
      temperature:e.detail.value
    })
  },


  // 编辑
  baocun(){
   if(this.data.xiugai==1){
    this.setData({
      xiugai:2,
      zhuangtai:false
    })
    console.log(this.data.zhuangtai)
   }else{
    this.setData({
      xiugai:1,
      zhuangtai:true
    })
    this.xiugai()
    this.xinxi()
   }
    
  },
  onLoad: function (options) {
    this.xinxi()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})